#ifndef __HIKARI_HOBJ__
#define __HIKARI_HOBJ__

#include "hikari.h"

using namespace std;
using namespace irr;
using namespace scene;
class hComponent;

class HObj{
protected:
	wstring name;
	scene::ISceneNode*node;
	AnimationData*animationData;
	bool updateable;
	bool renderUpdatable;
	vector<hComponent*>components;
	vector<hComponent*>renderComponents;
	btRigidBody*rigidBody;

public:
	HObj(scene::ISceneNode*node);
	virtual ~HObj(void);

	hComponent*getComponent(wstring&componentName);
	hComponent*getRenderComponent(wstring&componentName);
	hComponent*getRenderComponent(wchar_t*componentName);
	void addComponent(hComponent*component);
	void addRenderComponent(hComponent*component);
	vector<hComponent*>& getComponentList();
	vector<hComponent*>& getRenderComponentList();
	bool enableComponent(wstring&componentName, bool enable);
	bool isComponentEnabled(wstring&componentName);
	
	void setRigidBodyPosition(vector3df&position);
    vector3df getRigidBodyPosition();

	void setRigidBody(btRigidBody*body){
		rigidBody=body;
	}



	btRigidBody* getRigidBody(){
		return rigidBody;
	}

	bool useAnimationFromNode(HObj*object);

	ISceneNode*getInternalNode(){
		return node;
	}

	IMesh*getMesh(){
		IAnimatedMeshSceneNode*animatedNode=dynamic_cast<IAnimatedMeshSceneNode*>(getInternalNode());
		if(animatedNode!=NULL){
			return animatedNode->getMesh();
		}
		IMeshSceneNode*meshNode=dynamic_cast<IMeshSceneNode*>(getInternalNode());
		if(meshNode!=NULL){
			return meshNode->getMesh();
		}
		return NULL;
	}

	bool isUpdateable(){
		return updateable;
	}

	bool isRenderUpdatable(){
		return renderUpdatable;
	}

	void setUpdatealbe(bool updateable){
		this->updateable=updateable;
	}

	void setRenderUpdatealbe(bool updateable){
		this->renderUpdatable =updateable;
	}

	void setName(wstring&name){
		this->name=name;
	}	

	wstring&getName(){
		return name;
	}

	void setAnimationData(AnimationData*animData){
		animationData=animData;
	}

	AnimationData* getAnimationData(){
		return animationData;
	}

	virtual void animate(wstring&animationTrackName);
	virtual void animate(const wchar_t*animationTrackName);
	virtual void setPosition(vector3df position);
	virtual void setRotation(vector3df rotation);
	virtual void setScale(vector3df scale);

	virtual void move(vector3df offset);
	virtual void moveX(float offset);
	virtual void moveY(float offset);
	virtual void moveZ(float offset);

	virtual void moveRigidBody(vector3df&pos);
	virtual void moveRigidBodyX(float length);
	virtual void moveRigidBodyY(float length);
	virtual void moveRigidBodyZ(float length);

	virtual void turnX(float offset);
	virtual void turnY(float offset);
	virtual void turnZ(float offset);

	virtual void turnRigidBody(vector3df&axis, float angle);

	virtual void turnRigidBodyX(float angle);
	virtual void turnRigidBodyY(float angle);
	virtual void turnRigidBodyZ(float angle);

	virtual vector3df getPosition();
	virtual vector3df getRotation();
	virtual vector3df getScale();
};


#endif